#============================================================
#    Animated Sprite Utils
#============================================================
# - datetime: 2022-09-30 00:29:55
#============================================================

class_name AnimatedSpriteUtils


##  获取动画播放时长
static func get_animations_time(animated_sprite: AnimatedSprite2D, animations) -> float:
	if animations is String or animations is StringName:
		if animated_sprite:
			var count = animated_sprite.frames.get_frame_count(animations)
			var speed = 1.0 / animated_sprite.frames.get_animation_speed(animations)
			return count * speed / animated_sprite.speed_scale
	elif animations is Array:
		var time = 0.0
		for animation in animations:
			time += get_animations_time(animated_sprite, animation)
		return time
	else:
		assert(false, "不能是 String 和 Array 之外的类型")
	return 0.0

